home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / wordproc / wf_v31c.arj / DOCS / WF.017 < prev    next >
Text File  |  1992-01-31  |  21KB  |  586 lines

  1. .f3                              - # -              Chapter 17 - Mail Merge
  2. .rm70
  3. .tc
  4. .tc 17. MAIL MERGE ........................................#
  5. CHAPTER 17   MAIL MERGE
  6.  
  7. .imData Files
  8. .imMerge Printing
  9. .irFormletters;Formletters - see Merge Printing
  10. Mail Merge, or Merge Printing, is the process of inserting information
  11. into a document while it is being printed. The document is often
  12. printed several times with different information. The most common use
  13. of merge printing is to merge mailing list information into a form
  14. letter or mailing labels. Other applications include invoices,
  15. reports, and any other standard document that requires you to fill in
  16. blanks.
  17.  
  18. .ix   Master Document
  19. .ix   Template Document
  20. To merge print you need to create the form or template document (also
  21. called the master document). You usually need a data file as well. You
  22. then print the master document using the background print command Ctrl
  23. K P. Word fugue will obey the mail merge dot commands, and insert
  24. information in place of variables in your master document. If you are
  25. using a data file, a copy of the document will be produced for each
  26. set of information in the data file.
  27.  
  28. A master document contains the text of the document and the
  29. instructions for how the documents are to be produced. These
  30. instructions include variables and special merge print dot commands.
  31. An example would be a form letter and a data file of names and
  32. addresses.
  33.  
  34. .tc    Variables ..........................................#
  35. Variables
  36. .ix   Variables
  37. .ix   Mail merge labels
  38. .ixAmpersands;Ampersands in Master Document
  39. .ixLabels,;Labels, merge printing
  40. .ixFields;Fields
  41. .ixFields;Field Names
  42.  
  43. A variable is information that changes from one copy of the document
  44. to another. When you merge print, Word Fugue inserts information for
  45. each variable into each copy. This information can come from a data
  46. file, or you can be prompted for it when you print.
  47.  
  48. Each variable has a name, and you place the name of the variable into
  49. the master document wherever information is to be inserted. The actual
  50. information inserted in place of the variable is called data.
  51.  
  52. A variable name can contain up to 20 characters. You can use uppercase
  53. and lowercase letters interchangeably. You can make a name more
  54. readable by using hyphens (-) or underscores (_) to join words in the
  55. variable name.
  56.  
  57. Where you want to insert variable data, type the variable name between
  58. ampersands (&) in the text of the document:
  59.  
  60.    &person-name&                         Fred Nurk
  61.    &ADDress_1&                           The street
  62.    &city&, &state& &postcode&            Erehwon, XYZ 9000
  63.  
  64. If you have never set a value for a variable, it is termed
  65. uninitialised. These variables print their own name, to aid you in
  66. finding them. They usually happen when you misspell their name. word
  67. Fugue cannot match the misspelling, and so prints the name instead.
  68.  
  69. .tc    Merge Print Dot Commands ...........................#
  70. Merge Print Dot Commands
  71. .ix   Dot Commands
  72.  
  73. You type dot commands in the master document to tell Word Fugue the
  74. variable names and where to get the data that goes into them. If you
  75. do not obtain data for a variable name, Word Fugue will print the name
  76. instead. You cannot use a piece of data which is longer than 80
  77. characters. The total amount of data to be merged is limited by the
  78. memory available on your PC.
  79.  
  80. The following dot commands are available:
  81.  
  82.                 .DF filename delim
  83.                 .RV variable list
  84.                 .AV prompt,variable
  85.                 .SV variable=value
  86.                 .MA variable=equation
  87.                 .DM message
  88.                 .GO go to top of file and start again
  89.                 .WS Y or N for Wordstar compatible variable
  90.                     replacement
  91.  
  92. .ixDot Commands;  .DF - Data File
  93. .ix   Dot Commands
  94. .ix   Data File (.DF)
  95. .ixDF;.DF - Data File
  96. .ixData Files;   Selecting for merge printing (.DF)
  97. The .DF command defines the data file containing the variables to be
  98. merged into the text. If you follow the filename by at least one
  99. blank and another character, then that character is used as a
  100. delimiter instead of a comma
  101.  
  102.         eg .DF names.dat /
  103.  
  104. means that the file NAMES.DAT contains the variables to be read, and
  105. that the separator between variables is a slash (/). The default is
  106. comma (,).
  107.  
  108. .ixDot Commands;  .RV - Read Variable
  109. .ix   Read Variable .RV
  110. .ix   Data Files
  111. .ixCommas;Commas in data files
  112. .ixData Files;   Creating
  113. .ixData Files;   Examples
  114.  
  115. .ixRV;.RV - Read Variable
  116. .ixData Files;   Naming fields for merge printing (.RV)
  117. A data file consists of a series of records. Each record consists of
  118. one or more fields or items of information. For example, a mailing
  119. list has a field for name, a field for address line one, and a field
  120. for address line 2.
  121.  
  122. The .RV command defines the variables to be found on a single line of
  123. the data file. You can have more that one .RV to define different
  124. lines of your master document. If a line of the data file is exhausted
  125. before all the variables are read, the remainder are set to blank.
  126.  
  127.         eg .RV name,address1,address2
  128.  
  129. means that each line of the file will look like this:
  130.  
  131.         Joe Bloggs,17 West street,Newtown DG 9999
  132.  
  133. If you want to leave a variable blank, then leave it out:
  134.  
  135.         Joe Bloggs,,Newtown Post Office DG 9999
  136.  
  137. You can use a different separator, as defined on the .DF line, and put
  138. different variables on different lines:
  139.  
  140.         .DF names.dat /
  141.         .rv name,address1
  142.         .rv address2
  143.  
  144. .cp7
  145. Your file would then look like this:
  146.  
  147.         Joe Bloggs/17 Westside Ave.,
  148.         Newtown DG 9999
  149.  
  150. .ixData Files;   Creating
  151. Make sure that the fields are in the same order in all records.
  152. Separate fields with commas or the separator you defined on the .DF
  153. line. Make sure that the fields on a record are consistent with the
  154. order you defined in the .RV line(s). If a field contains a comma,
  155. enclose the entire field in quotation marks. If a field is empty (you
  156. have no information for it in this record), indicate the blank field
  157. with a space and a comma.
  158.  
  159. NOTE - The rules above are very important. If you enter data
  160.        incorrectly, your merge printing will not print correctly.
  161.  
  162. .ixDot Commands;  .AV - Ask for Variable
  163. .ix   Dot Commands
  164. .ix   Ask for Variable .AV
  165. .ixAV;.AV - Ask for Variable
  166. The .AV line will prompt you to enter the contents of the variable.
  167. You can include an optional prompt:
  168.  
  169.         .AV Address1
  170.  
  171. will display   ADDRESS1?  and open a window for you to enter the
  172. value.
  173.  
  174.         .AV Enter the address,address1
  175.  
  176. will display  Enter the address  and open a window for you to enter
  177. the value.
  178.  
  179. .ixDot Commands;  .SV - Set Variable
  180. .ix   Set Variable (.SV)
  181. .ixSV;.SV - Set Variable
  182. The .SV line sets the variable to the value:
  183.  
  184.         .SV vara,this is the value for variable A
  185.         .SV addr= This is the address
  186.  
  187. You can use either comma (,) or equals sign (=). Leading spaces in the
  188. variable are ignored. If you want to include leading spaces, you
  189. should enclose the data within single or double quotes. If you start
  190. with a single quote, you must end with a single quote, and vice
  191. versa:
  192.  
  193.         .SV company= "   Fugue Software  "
  194.  
  195. You can set the maximum length of a variable by placing the characters
  196. /L and a length, or /R and a length, or /C and a length, depending on
  197. whether you want your data Left justified or Right justified or
  198. Centred, after the variable name:
  199.  
  200.         .SV A/L15=Joe Bloggs
  201.         .SV B/R15=Joe Bloggs
  202.         .SV C =Joe Bloggs
  203.         .SV D/C15=Joe Bloggs
  204.  
  205.         gives
  206.            A = "Joe Bloggs     "
  207.            B = "     Joe Bloggs"
  208.            C = "Joe Bloggs"
  209.            D = "   Joe Bloggs  "
  210.  
  211. If the line were too long, it would be truncated at the length
  212. specified.
  213.  
  214. .ixDot Commands;  .MA - Mathematical Calculations
  215. .ix   Mathematical calculations .MA
  216. .ixMA;.MA - Mathematical calculations
  217. The .MA line allows you to compute values and store them in another
  218. variable:
  219.  
  220.         .MA VARB=25*10
  221.         .MA varc= &vara&+&varb&
  222.         .MA total_price,&price&*(1-&discount&) * &qty&
  223.  
  224. The text within the '&' are other variables that will be replaced
  225. before the calculation is done. You can use any functions and
  226. operators that are provided by the pop up calculator, including
  227. booleans, since the same code is used for evaluation.
  228.  
  229. .cp5
  230. .ix   Dot Commands
  231. .ix   Mathematical calculations .MA
  232. .ixMA;.MA - Mathematical calculations
  233. .ixCalculations;Calculations while merge printing (.MA)
  234. You can also have limited formatting when set in the .MA command.
  235. Follow the variable by $ for dollar format (2 decimal places) and by !
  236. for integer format. The default is as many decimal places as required:
  237.  
  238.        .MA  a = 1.2345
  239.           &a&           gives 1.2345
  240.  
  241.        .MA  a$ = 1.2345
  242.           &a&           gives 1.23
  243.  
  244.        .MA  a! = 1.2345
  245.           &a&           gives 1
  246.  
  247. The value is actually truncated to the number of places specified when
  248. assigned to the variable
  249.  
  250. .ixDot Commands;  .DM - Display Message
  251. .ix   Display message .DM
  252. .ixDM;.DM - Display Message
  253. .ixMessages;Messages while printing
  254. The .DM line will display the following message. You can include
  255. variables which will be substituted before the message is displayed.
  256.  
  257.         .RV varb
  258.         .DM message is varb = &varb&
  259.  
  260. will display
  261.  
  262.        message is varb = the value of variable b
  263.  
  264. .ixDot Commands;  .GO - Go to next letter
  265. .ix   Dot Commands
  266. .ix   GO command .GO
  267. .ixGO;.GO - GO command
  268. The .GO is used to exit from the current print and go back to the top
  269. of the file (assuming that there are more records to be printed)
  270.  
  271. .cp8
  272. .ixDot Commands;  .WS - Wordstar Compatibility
  273. .ix   Dot Commands
  274. .ix   Wordstar compatibility .WS
  275. .ixWS;.WS - Wordstar compatibility
  276. The .WS is used to determine how variables in the text are replaced.
  277. You can set Y or N. The default is Y. All variables must be embedded
  278. within &s to be recognized and replaced. With the default, this is all
  279. that is needed:
  280.  
  281.                 &address1&
  282.                 &address2&
  283.  
  284. Setting .WS to N will mean that the variables within the text body
  285. must also be embedded inside print control brackets:
  286.  
  287.                 {.&address1&}
  288.                 {.&address2&}
  289.  
  290. .tc    Merge Printing Conditional Commands ................#
  291. .ix   Conditional Commands
  292. Merge Printing Conditional Commands
  293.  
  294. Additional printing commands for evaluating conditional expressions
  295. and controlling the text that is printed.
  296.  
  297.                 .IF condition           is the IF condition
  298.                 .EL                     is the else
  299.                 .EI                     ends the IF expression.
  300.  
  301. You must have an .EI for every .IF, but you do not need to have .EL
  302. (else). The lines following the .IF are evaluated if the .IF were
  303. true, while the lines following the .EL are evaluated if the condition
  304. were false.
  305.  
  306. .tc      The IF Condition .................................#
  307. The IF Condition
  308.  
  309. .ixDot Commands;  .IF - IF condition
  310. .ix   Dot Commands
  311. .ix   Conditional Commands
  312. .ix   IF condition
  313. .ixIF;.IF - IF Condition
  314. Whether a condition is true is usually determined by comparing one
  315. item with another. If an item can be considered numeric (ie it
  316. consists only of digits), it is converted to a number before the
  317. comparison is done. Otherwise the comparison is done as text. The
  318. following comparisons are available:
  319.  
  320.         Operator        Meaning
  321.  
  322.         =               is the same as
  323.         <               is numerically less than or
  324.                         comes alphabetically before
  325.         >               is numerically greater than
  326.                         or comes alphabetically after
  327.         <=              is less than or equal to
  328.         >=              is greater than or equal to
  329.         <>              is not equal or not the same
  330.  
  331. The most common way to specify a condition to be evaluated is
  332.  
  333.         .IF item1 operator item2
  334.  
  335. .cp6
  336. For example, you can compare a merge print variable to a constant (a
  337. word, phrase or number that does not change) or to another merge print
  338. variable:
  339.  
  340.         .IF &pet& = dog
  341.         .IF &pet& = &pet_2&
  342.         .if &amt& = 12.35
  343.  
  344. In the first case, the condition is true if the value of the variable
  345. PET is dog. Note that uppercase and lower case are significant. In the
  346. second case, the condition is true if the value of the first variable
  347. is equal to the second variable. In the third case, the condition is
  348. true if the value of the variable is numerically equal to 12.35.
  349.  
  350. With strings of text, you should enclose them in quotes if leading or
  351. trailing spaces are significant. For 2 text items to be considered the
  352. same (=), they must consist of exactly the same characters.
  353.  
  354.         .IF "&pet&" = "    dog"
  355.         .if "&pet&" = "    dog's"
  356.  
  357. mean that the value of the variable PET must have 4 leading spaces.
  358.  
  359. Words are considered in alphabetic order, so that the following are
  360. true:
  361.  
  362.         .if cat < catalog
  363.         .IF catalog     >     cat
  364.  
  365. since cat comes before catalog in the dictionary.
  366.  
  367. In alphabetic order numbers come before letters. Note that the first
  368. variable determines the type of comparison. Text that cannot be
  369. converted to numbers for a numeric comparison is considered to be
  370. zero:
  371. .ix   IF condition
  372. .ixIF;.IF - IF Condition
  373.  
  374.         .if 2<apple
  375.  
  376. .ix   Dot Commands
  377. .ix   Conditional Commands
  378. is FALSE since 2 determines that the comparison will be numeric, and
  379. apple converts to the number 0. Whereas:
  380.  
  381.         .if apple>2
  382.  
  383. is TRUE, since apple is alphabetically after 2.
  384.  
  385. You can also use the .if command with just one variable name, in which
  386. case the condition is true if the variable is not zero or blank.
  387.  
  388.         .if &pet&
  389.  
  390. will be true if the variable PET contains a non zero non blank value.
  391.  
  392. Note 1. that a variable that has never been initialised will return a
  393.         blank in this situation.
  394.  
  395.      2. If your variable will contain text with spaces, enclose the
  396.         variable in quotes to perform the test:
  397.  
  398.        .if "&pet&"
  399.  
  400. .cp6
  401. .tc        Complex Conditions .............................#
  402. Complex Conditions
  403.  
  404. You can use mathematical equations on either side of the relational
  405. operator, and can join conditions together by using AND and OR. The
  406. following additional operators are available:
  407.  
  408.         AND             true and true => true
  409.                         anything else => false
  410.         OR              false and false => false
  411.                         anything else   => true
  412.  
  413.         XOR             true xor false  => true
  414.                         false xor true  => true
  415.                         true xor true   => false
  416.                         false xor false => false
  417.  
  418.         NOT             not true        => false
  419.                         not false       => true
  420.  
  421. .cp5
  422. You should use brackets to group parts of the condition for easier
  423. understanding:
  424.  
  425.     .IF (&PET& = dog) and (&pet2& = cat)
  426.     .IF ((&pet& = dog) or (&pet& = cat)) and (&income& > 25000)
  427.  
  428. .cp12
  429. .ix   Dot Commands
  430. .tc      The End If .......................................#
  431. .ix   Conditional Commands
  432. .ix   End IF
  433. .ixIF;.IF - IF Condition
  434. .ix   IF condition
  435. The End If
  436.  
  437. .ixDot Commands;  .EI - End IF
  438. .ixEI;.EI - End IF
  439. The .IF dot command is followed by the commands and text to be printed
  440. if the condition is true. You must signify to Word Fugue where the
  441. text finishes, so the program knows where to start again if the
  442. condition is false. You indicate this by using the dot command .EI
  443. (End If)
  444.  
  445. Almost anything can come between a .IF and its corresponding .EI. This
  446. can include text or other dot commands:
  447.  
  448.         .IF (&debt_age& > 30) and (&debt_age& < 60)
  449.         According to our records, you account is overdue. Maybe you
  450.         have overlooked our invoice. Could you please pay $&amt& as
  451.         soon as possible? If you have paid in the last few days,
  452.         please disregard this warning.
  453.         .EI
  454.         .if (&debt_age&>=60)
  455.         .fi nasty.doc
  456.         .ei
  457.  
  458. In this example, if a debt is between 30 and 60 days old, a warning is
  459. printed. If it is 60 days or more overdue, a stronger message is
  460. printed. If it is under 30 days, no message is printed.
  461.  
  462. .cp9
  463. .tc      The Else Condition ...............................#
  464. The Else Condition
  465.  
  466. .ixDot Commands;  .EL - ELSE
  467. .ix   ELSE command
  468. .ix   IF condition
  469. .ixEL;.EL - ELSE
  470. The else condition says what action to take if the corresponding IF
  471. were false. The phrase ELSE is represented by the dot command .EL.
  472. The previous example could be redone as:
  473.  
  474.         .if (&debt_age&>=60)
  475.         .fi nasty.doc
  476.         .el
  477.         According to our records, you account is overdue. Maybe you
  478.         have overlooked our invoice. Could you please pay $&amt& as
  479.         soon as possible? If you have paid in the last few days,
  480.         please disregard this warning.
  481.         .EI
  482.  
  483. You should note a subtle difference here. In the first example, a debt
  484. could be under 30 days, and no message would be printed. In this
  485. example, all debts are assumed to be overdue, so a warning will always
  486. be printed if the debt is under 60 days old.
  487.  
  488. .tc      Nested Ifs .......................................#
  489. Nested Ifs
  490.  
  491. You can use conditional print commands and have Word Fugue choose
  492. among three or more alternatives by nesting the commands. For example,
  493. you may want to have different text for debts that are over 90 days,
  494. over 60 days, and over 30 days, as well as not printing a warning if
  495. they are less than 30 days. You could set up individual IFs as in the
  496. first example, and each IF must be phrased in such a way as to exclude
  497. all the other conditions. (This is why we tested > 30 days and < 60
  498. days). Alternatively, you could separate each condition by ELSEs, and
  499. simplify the conditions:
  500.  
  501.   If the debt is more than 90 days old, insert SOLICITR.DOC, otherwise
  502.   if the debt is more than 60 days old, insert NASTY.DOC, or else if
  503.   the debt is more than 30 days old print a warning, or if the debt is
  504.   less than 2 days old, offer a discount for prompt payment:
  505.  
  506. .CP16
  507. .ix   Dot Commands
  508. .ix   Conditional Commands
  509. .ix   IF condition
  510.     ┌───.IF &debt_age& > 90
  511.     │   .fi solicitr.doc
  512.     │   .el
  513.     │┌──.if &debt_age& > 60
  514.     ││  .fi nasty.doc
  515.     ││  .el
  516.     ││┌─.if &debt_age& > 30
  517.     │││ .fi warning.doc
  518.     │││ .el
  519.     │││┌.if &debt_age& < 2
  520.     ││││.fi discount.doc
  521.     │││└.ei
  522.     ││└─.ei
  523.     │└──.ei
  524.     └───.ei
  525.  
  526. Every .IF must have a corresponding .EI command. There are 4 IFs so
  527. there must be 4 EIs. The lines shown link up the IFs with their
  528. corresponding EIs.
  529.  
  530. .tc      Command Files ....................................#
  531. Command Files
  532. .ix   Master Document
  533. .ix   Template Document
  534. .ix   Command Files
  535. .imCommand Files
  536. .ix   in Merge Printing
  537. .imMerge Printing
  538.  
  539. A command file is a file that contains only (or mainly) dot commands.
  540. Command files can be very useful for controlling merge printing or for
  541. chaining together the chapters of a large document by use of the .FI
  542. file include command:
  543.  
  544.   Example 1
  545.  
  546.        ┌─────────────────────────┐
  547.        │.FI letter.txt           │
  548.        │.pa                      │
  549.        │.fi proposal.doc         │
  550.        │.pa                      │
  551.        │.fi specs.doc            │
  552.        └─────────────────────────┘
  553.  
  554. .cp20
  555. .ix   Dot Commands
  556. .ix   Conditional Commands
  557.   Example 2
  558.  
  559.        ┌─────────────────────────────────────────────────────┐
  560.        │.DF names.txt                                        │
  561.        │.RV first_name,last_name                             │
  562.        │.RV address_1                                        │
  563.        │.RV address_2                                        │
  564.        │.RV city,state,postcode                              │
  565.        │.if &postcode&<2000                                  │
  566.        │.fi special.doc                                      │
  567.        │.el                                                  │
  568.        │.if (&postcode&=2620) and (&city& = Queanbeyan)      │
  569.        │.sv state = NSW                                      │
  570.        │.ei                                                  │
  571.        │.fi normal1.doc                                      │
  572.        │.if (&postcode&>=2000) and (&postcode& <=2110)       │
  573.        │.fi offer.doc                                        │
  574.        │.ei                                                  │
  575.        │.ei                                                  │
  576.        └─────────────────────────────────────────────────────┘
  577.  
  578. .CP5
  579. This document reads a data file called NAMES.TXT, and prints a special
  580. letter if the postcode is less than 2000. Otherwise, it ensures that
  581. all Queanbeyan addresses with postcode 2620 have the state set to NSW
  582. and not ACT. (The postcode 2620 is allocated to parts of ACT and NSW
  583. as well). It then prints a normal letter to these people. If they live
  584. in areas around Sydney (postcode 2000 to 2110), it also prints a
  585. special offer.
  586.